﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MyBBS
{
    public class GlobalApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Post",
                "Post",
                new { controller = "Post", action = "Index", id = 0 }
                );

            routes.MapRoute(
                "Category",
                "Post/Category/{id}",
                new { controller = "Post", action = "Category", id = 0 }
                );

            routes.MapRoute(
                "Tag",
                "Post/Tag/{id}",
                new { controller = "Post", action = "Tag", id = 0 }
                );

            routes.MapRoute(
                "Show",
                "Post/Show/{id}",
                new { controller = "Post", action = "Show", id = 1 }
                );

            //routes.MapRoute(
            //    "Login",
            //    "User/Login/{userName}&{password}",
            //    new { controller = "User", action = "Login", userName="", password="" }
            //    );

            //routes.MapRoute(
            //    "SignUp",
            //    "User/SignUp/{userName}&{password}&{email}",
            //    new { controller = "User", action = "SignUp" }
            //    );

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Post", action = "Index", id = "" }  // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            BootStrapper.ConfigureStructureMap();

            ControllerBuilder.Current.SetControllerFactory(
                    new MyBBS.Controllers.StructureMapControllerFactory()
                );
        }
    }
}